//
//  QuDanSquareMainController.m
//  QuDanOEM
//
//  Created by xiaohuang on 2021/10/18.
//

#import "QuDanSquareMainController.h"
#import "QuDanSquareRecommController.h"
#import "QuDanSquareAttentionController.h"
#import "QuDanHomeDetailController.h"
#import "QuDanSendDongTaiController.h"
@interface QuDanSquareMainController ()
<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;
@property (nonatomic,strong)UIButton *sendBtn;
@end
@implementation QuDanSquareMainController
- (UIButton *)sendBtn
{
    if (!_sendBtn) {
        _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sendBtn setImage:[UIImage imageNamed:@"square_send"] forState:UIControlStateNormal];
        [_sendBtn addTarget:self action:@selector(actionSquareSend:) forControlEvents:UIControlEventTouchUpInside];
        [_sendBtn sizeToFit];
    }
    return _sendBtn;
}
-(void)actionSquareSend:(UIButton *)btn
{
    NSLog(@"发布动态");
    QuDanSendDongTaiController *dongtaivc = [[QuDanSendDongTaiController alloc]init];
    dongtaivc.hidesBottomBarWhenPushed = YES;
    dongtaivc.isSquare = YES;
    [self.navigationController pushViewController:dongtaivc animated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.sendBtn];
    [self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.top.offset(Height_StatusBar);
        make.width.offset(72);
        make.height.offset(44);
    }];
    [self setupSqpareNavUI];
}
-(void)setupSqpareNavUI{
    NSArray *titleArr = @[@"推荐",@"关注"];
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.indicatorStyle = SGIndicatorStyleFixed;
    configure.showBottomSeparator = NO;
    configure.equivalence = NO;
    configure.titleSelectedColor = [UIColor blackColor];
    configure.titleColor         = [UIColor grayColor];
    configure.titleFont          = [UIFont systemFontOfSize:17];
    configure.indicatorColor =  QD_RGB(13, 36, 87);
    configure.indicatorFixedWidth  = 80;
    configure.indicatorColor = [UIColor clearColor];
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, Height_StatusBar, self.view.frame.size.width-100, 44) delegate:self titleNames:titleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    QuDanSquareRecommController *recommendvc = [[QuDanSquareRecommController alloc]init];
    QuDanSquareAttentionController *attentionvc = [[QuDanSquareAttentionController alloc]init];
    NSArray *childArr = @[recommendvc, attentionvc];
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = self.view.frame.size.height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), self.view.frame.size.width, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
{
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
{
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
- (SAViewControllerNaviType)customNaviType{
    return SAViewControllerNaviTypeHide;
}
@end
